(function () {
    var x = 0, y = 0;
    var dx = 5, dy = 5;
    var interval = 50;

    function bounce() {
        var box = document.getElementById("slide-container");

        var boundX = window.innerWidth - box.offsetWidth;
        var boundY = window.innerHeight - box.offsetHeight;
        if (x > boundX) {
            x = boundX;
            dx = -Math.abs(dx);
        } else if (x < 0) {
            x = 0;
            dx = Math.abs(dx);
        }
        if (y > boundY) {
            y = boundY;
            dy = -Math.abs(dy);
        } else if (y < 0) {
            y = 0;
            dy = Math.abs(dy);
        }
        box.style.left = x + "px";
        box.style.top = y + "px";
        x += dx;
        y += dy;

        setTimeout(bounce, interval);
    }

    bounce();
})();
